<?php
  
  header("Content-type:text/html;charset=utf-8");
  	
  	$name = $_POST["userName"];
  	$pwd = $_POST["userPwd"];
  	// 连接数据库
  	$conn = mysql_connect("localhost","root","root");
  
  	if($conn){
		// echo "成功连接";
		// 指定数据库
  		mysql_select_db("2005");
  	}
  	// 查询
  	$result = mysql_query("select * from stu where name = '$name'",$conn);
    // $result = mysql_query("insert into stu values('$name','$pwd')",$conn);
  	if(mysql_num_rows($result) >0){
  		echo "1";
  	}else{
  		mysql_query("insert into stu value ('$name','$pwd')",$conn);
  		echo "0";
		// echo $pwd;
  	}
  	
  	mysql_close($conn);
?>